package test.br.com.lh.urabuilder.business
{
	import br.com.lh.urabuilder.business.XmlManager;
	import br.com.lh.urabuilder.model.UraModelLocator;
	import br.com.lh.urabuilder.view.ActionComponent;
	
	import flexunit.framework.TestCase;
	import flexunit.framework.TestSuite;
	
	import mx.containers.Canvas;

	public class XmlManagerImplTest extends TestCase
	{
		private var modelLocator:UraModelLocator;
		
		public function XmlManagerImplTest(methodName:String=null)
		{
			super(methodName);
		}
		
		public static function suite():TestSuite{
			var ts:TestSuite = new TestSuite();
			ts.addTest(new XmlManagerImplTest("clearedUraShouldKeepSessionData"));
			return ts;
		} 
		
		public override function setUp():void{
			var drawingCanvas:Canvas = new Canvas();
			UraModelLocator.modelLocator = null;
			modelLocator =UraModelLocator.getInstance(drawingCanvas);
		}
		
		
		
		public function clearedUraShouldKeepSessionData():void{
			var xmlManager:XmlManager = modelLocator.xmlManager;
			var actionComponent:ActionComponent = new ActionComponent();
			actionComponent.loadComponent("PlaySound",0,0,0);
			xmlManager.insertElement(actionComponent.uraAction);
			assertTrue(xmlManager.getPrettyPrintedXml().length > 0)
			modelLocator.sessionHolder.uraId = "1";
			xmlManager.clearUra();
			assertEquals(0,xmlManager.getPrettyPrintedXml().length)
			assertEquals("1",xmlManager.getUraXml().uraId);
		}
		
	}
}